package com.yuqiaotech.zcj.service.impl;

import java.io.Serializable;
import java.util.List;

import org.hibernate.criterion.DetachedCriteria;

import com.yuqiaotech.zcj.dao.GenericDao;
import com.yuqiaotech.zcj.service.GenericManager;
/**
 * 本类的实现实际上只是简单的调用了GenericDao的方法。
 *
 * @param <T>
 * @param <PK>
 */
public class GenericManagerImpl<T, PK extends Serializable> implements GenericManager<T, PK>{

	private GenericDao<T, PK> genericDao;

	public void delete(T entity) {
		genericDao.delete(entity);
	}
	public void update(T entity) {
		genericDao.update(entity);
	}

	public List findByHql(String hql, Object... params) {
		return genericDao.findByHql(hql, params);
	}


	public T get(PK id) {
		return genericDao.get(id);
	}


	public void remove(PK id) {
		T entity = get(id);
		genericDao.delete(entity);
	}


	public T save(T entity) {
		return genericDao.save(entity);
	}

	public T findUniqueBy(Class persistentClass,String propertyName, Object value){
		return (T) this.genericDao.findUniqueBy(persistentClass, propertyName, value);
	}
	
	public int executeUpdate(String hql, Object... params) {
		return this.genericDao.executeUpdate(hql, params);
	}
	
	
	public GenericDao<T, PK> getGenericDao() {
		return genericDao;
	}

	public void setGenericDao(GenericDao<T, PK> genericDao) {
		this.genericDao = genericDao;
	}

}